/**
*Hanoi Problem
*Show the progress in solving Hanoi problem.
*/

#include <cstdio>
#include <iostream>

using namespace std;

int moveTime=0;

/*Display the movement*/ 
void move(char begin, char end)
{
    moveTime++;
    cout<<begin<<"---->"<<end<<endl;
}

/ * This is the main body of the algorithm
* Indicates that the n plates move from A to C, by means of B. Use the recursion.
* Reduction Governance thought: f (n) = 2f (n-1) +1
* Implementation of the code cleverly that f (n-1) when the start and at the end of the mobile is not the same.
* /
int hanoi(int n ,char A,char B,char C)
{
    if( n==1 ) {
//        return 0;
        move(A,C);
        return 0;
    }
    hanoi(n-1,A,C,B);
    move(A,C);
    hanoi(n-1,B,A,C);
    return 0;
}

int main()
{
    int numPlate=3;
    hanoi(numPlate,'A','B','C');
    cout<<"Move times :"<<moveTime<<endl;
    cout<<"GameOver!"<<endl;
    getchar();
    return 0;
    
}
